//
//  FriendStore.m
//  NewPro
//
//  Created by RYX on 2018/10/26.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "FriendStore.h"
#import "FriendModel.h"

@implementation FriendStore

#pragma mark - 获取合伙人列表
- (void)getFriendListWithCustomId:(NSString *)customId andType:(NSString *)type andKey:(NSString *)key andPx:(NSString *)px Success:(void(^)(NSArray *listArr, NSString *headImg,NSString *name,NSString *leve))success Failure:(void(^)(NSError *error))failure{
    
    NSString *url = [NSString stringWithFormat:@"%@/api/courseAlly/courseList",IP];
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:customId forKey:@"customId"];
    [dic setObject:type forKey:@"type"];
    [dic setObject:px forKey:@"px"];
    
    if (key.length > 0) {
        
        [dic setObject:key forKey:@"key"];
    }
    
    /*
     {
     customId = 14;
     px = 0;
     type = 1;
     }
     */

    [HttpTool postUrlWithString:url parameters:dic success:^(id responseObject) {
        
        NSError *error = [HttpTool inspectError:responseObject];
        
        if (error == nil) {
            
            NSArray *listArr = [FriendModel mj_objectArrayWithKeyValuesArray:responseObject[@"data"][@"items"]];
            
            NSString *headImg = responseObject[@"data"][@"headImg"];
            
            NSString *name = responseObject[@"data"][@"name"];
            
            NSString *leve = (NSString *)responseObject[@"data"][@"levelAmount"];
            
            success(listArr, headImg, name, leve);
            
        }else{
            
            failure(error);
        }
        
    } failure:^(NSError *error) {
       
        failure(error);
    }];
}

@end
